/**
 * Copyright (c) 2018 qar All rights reserved.
 *
 * https://www.qar.io
 *
 * 版权所有，侵权必究！
 */

package com.example.feign;

import com.example.constant.ServiceConstant;
import com.example.constant.ServicePrefixConstant;
import com.example.feign.fallback.ParamsFeignClientFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 参数接口
 *
 * @author Mark sunlightcs@gmail.com
 */
@FeignClient(name = ServiceConstant.ADMIN_SERVER, contextId = "ParamsFeignClient", fallback = ParamsFeignClientFallbackFactory.class)
public interface ParamsFeignClient {

    /**
     * 根据参数编码，获取参数值
     * @param paramCode  参数编码
     * @return  返回参数值
     */
    @GetMapping(ServicePrefixConstant.ADMIN_SERVER + "/params/code/{paramCode}")
    String getValue(@PathVariable("paramCode") String paramCode);

    /**
     * 根据参数编码，更新参数值
     * PathVariable sys/params/code/{paramCode}
     * @RequestParam("paramValue")
     * http://192.168.88.1:8082/sys/params/code/MAIL_CONFIG_KEY?paramValue=%7B%22smtp%22%3A%22smtp.qq.com%22%2C%22port%22%3A25%2C%22username%22%3A%221020066395%40qq.com%22%2C%22password%22%3A%22dzxaidtxtufhbdac%22%7D
     * @param paramCode  参数编码
     * @param paramValue  参数值
     */
    @PutMapping(ServicePrefixConstant.ADMIN_SERVER + "/params/code/{paramCode}")
    void updateValueByCode(@PathVariable("paramCode") String paramCode, @RequestParam("paramValue") String paramValue);

}